import Mock from "mockjs"; // 引入mockjs
import utils from "../../../src/utils/utils";
const Random = Mock.Random;

// http://mockjs.com/
export default [
  {
    url: "/admin/api/account.listing",
    method: "post",
    response: (options) => {
      const rows = [];
      const total = 112;
      let cnt = options.body.rows;
      if (options.body.rows * options.body.page > total) {
        cnt = total - options.body.rows * (options.body.page - 1);
      }
      for (let i = 0; i < cnt; i++) {
        const template = {
          name: Random.cname(),
          accountId: Mock.mock({
            "regexp|3": /\d{5,10}\-/,
          }).regexp,
          account: Random.email(),
          employeeNumber: Random.natural(),
          orgName: Random.region(),
          deptName: Random.city(),
          status: Mock.mock({
            "array|1": ["0", "1"],
          }).array,
        };
        rows.push(template);
      }

      return {
        code: 200,
        total: total,
        rows: rows,
      };
    },
  },
];
